(0) Obligation:

Clauses:

max(X, Y, X) :- less(Y, X).
max(X, Y, Y) :- less(X, s(Y)).
less(0, s(X1)).
less(s(X), s(Y)) :- less(X, Y).

Query: max(g,a,a)

(1) PrologToPrologProblemTransformerProof (SOUND transformation)

Built Prolog problem from termination graph ICLP10.

(2) Obligation:

Clauses:

lessA(0, s(T31)).
lessA(s(T38), s(T37)) :- lessA(T38, T37).
lessB(0, s(T68)).
lessB(s(T73), s(T75)) :- lessB(T73, T75).
maxC(s(T13), 0, s(T13)).
maxC(s(T23), s(T24), s(T23)) :- lessA(T24, T23).
maxC(0, T54, T54).
maxC(s(T59), T61, T61) :- lessB(T59, T61).
maxC(0, T87, T87).
maxC(s(T92), T94, T94) :- lessB(T92, T94).

Query: maxC(g,a,a)

(3) PrologToPiTRSProof (SOUND transformation)

We use the technique of [TOCL09]. With regard to the inferred argument filtering the predicates were used in the following modes:
maxC_in: (b,f,f)
lessA_in: (f,b)
lessB_in: (b,f)
Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

maxC_in_gaa(s(T13), 0, s(T13)) → maxC_out_gaa(s(T13), 0, s(T13))
maxC_in_gaa(s(T23), s(T24), s(T23)) → U3_gaa(T23, T24, lessA_in_ag(T24, T23))
lessA_in_ag(0, s(T31)) → lessA_out_ag(0, s(T31))
lessA_in_ag(s(T38), s(T37)) → U1_ag(T38, T37, lessA_in_ag(T38, T37))
U1_ag(T38, T37, lessA_out_ag(T38, T37)) → lessA_out_ag(s(T38), s(T37))
U3_gaa(T23, T24, lessA_out_ag(T24, T23)) → maxC_out_gaa(s(T23), s(T24), s(T23))
maxC_in_gaa(0, T54, T54) → maxC_out_gaa(0, T54, T54)
maxC_in_gaa(s(T59), T61, T61) → U4_gaa(T59, T61, lessB_in_ga(T59, T61))
lessB_in_ga(0, s(T68)) → lessB_out_ga(0, s(T68))
lessB_in_ga(s(T73), s(T75)) → U2_ga(T73, T75, lessB_in_ga(T73, T75))
U2_ga(T73, T75, lessB_out_ga(T73, T75)) → lessB_out_ga(s(T73), s(T75))
U4_gaa(T59, T61, lessB_out_ga(T59, T61)) → maxC_out_gaa(s(T59), T61, T61)
maxC_in_gaa(s(T92), T94, T94) → U5_gaa(T92, T94, lessB_in_ga(T92, T94))
U5_gaa(T92, T94, lessB_out_ga(T92, T94)) → maxC_out_gaa(s(T92), T94, T94)

The argument filtering Pi contains the following mapping:
maxC_in_gaa(x1, x2, x3)  =  maxC_in_gaa(x1)
s(x1)  =  s(x1)
maxC_out_gaa(x1, x2, x3)  =  maxC_out_gaa
U3_gaa(x1, x2, x3)  =  U3_gaa(x3)
lessA_in_ag(x1, x2)  =  lessA_in_ag(x2)
lessA_out_ag(x1, x2)  =  lessA_out_ag(x1)
U1_ag(x1, x2, x3)  =  U1_ag(x3)
0  =  0
U4_gaa(x1, x2, x3)  =  U4_gaa(x3)
lessB_in_ga(x1, x2)  =  lessB_in_ga(x1)
lessB_out_ga(x1, x2)  =  lessB_out_ga
U2_ga(x1, x2, x3)  =  U2_ga(x3)
U5_gaa(x1, x2, x3)  =  U5_gaa(x3)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog

(4) Obligation:

Pi-finite rewrite system:
The TRS R consists of the following rules:

maxC_in_gaa(s(T13), 0, s(T13)) → maxC_out_gaa(s(T13), 0, s(T13))
maxC_in_gaa(s(T23), s(T24), s(T23)) → U3_gaa(T23, T24, lessA_in_ag(T24, T23))
lessA_in_ag(0, s(T31)) → lessA_out_ag(0, s(T31))
lessA_in_ag(s(T38), s(T37)) → U1_ag(T38, T37, lessA_in_ag(T38, T37))
U1_ag(T38, T37, lessA_out_ag(T38, T37)) → lessA_out_ag(s(T38), s(T37))
U3_gaa(T23, T24, lessA_out_ag(T24, T23)) → maxC_out_gaa(s(T23), s(T24), s(T23))
maxC_in_gaa(0, T54, T54) → maxC_out_gaa(0, T54, T54)
maxC_in_gaa(s(T59), T61, T61) → U4_gaa(T59, T61, lessB_in_ga(T59, T61))
lessB_in_ga(0, s(T68)) → lessB_out_ga(0, s(T68))
lessB_in_ga(s(T73), s(T75)) → U2_ga(T73, T75, lessB_in_ga(T73, T75))
U2_ga(T73, T75, lessB_out_ga(T73, T75)) → lessB_out_ga(s(T73), s(T75))
U4_gaa(T59, T61, lessB_out_ga(T59, T61)) → maxC_out_gaa(s(T59), T61, T61)
maxC_in_gaa(s(T92), T94, T94) → U5_gaa(T92, T94, lessB_in_ga(T92, T94))
U5_gaa(T92, T94, lessB_out_ga(T92, T94)) → maxC_out_gaa(s(T92), T94, T94)

The argument filtering Pi contains the following mapping:
maxC_in_gaa(x1, x2, x3)  =  maxC_in_gaa(x1)
s(x1)  =  s(x1)
maxC_out_gaa(x1, x2, x3)  =  maxC_out_gaa
U3_gaa(x1, x2, x3)  =  U3_gaa(x3)
lessA_in_ag(x1, x2)  =  lessA_in_ag(x2)
lessA_out_ag(x1, x2)  =  lessA_out_ag(x1)
U1_ag(x1, x2, x3)  =  U1_ag(x3)
0  =  0
U4_gaa(x1, x2, x3)  =  U4_gaa(x3)
lessB_in_ga(x1, x2)  =  lessB_in_ga(x1)
lessB_out_ga(x1, x2)  =  lessB_out_ga
U2_ga(x1, x2, x3)  =  U2_ga(x3)
U5_gaa(x1, x2, x3)  =  U5_gaa(x3)

(5) DependencyPairsProof (EQUIVALENT transformation)

Using Dependency Pairs [AG00,LOPSTR] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

MAXC_IN_GAA(s(T23), s(T24), s(T23)) → U3_GAA(T23, T24, lessA_in_ag(T24, T23))
MAXC_IN_GAA(s(T23), s(T24), s(T23)) → LESSA_IN_AG(T24, T23)
LESSA_IN_AG(s(T38), s(T37)) → U1_AG(T38, T37, lessA_in_ag(T38, T37))
LESSA_IN_AG(s(T38), s(T37)) → LESSA_IN_AG(T38, T37)
MAXC_IN_GAA(s(T59), T61, T61) → U4_GAA(T59, T61, lessB_in_ga(T59, T61))
MAXC_IN_GAA(s(T59), T61, T61) → LESSB_IN_GA(T59, T61)
LESSB_IN_GA(s(T73), s(T75)) → U2_GA(T73, T75, lessB_in_ga(T73, T75))
LESSB_IN_GA(s(T73), s(T75)) → LESSB_IN_GA(T73, T75)
MAXC_IN_GAA(s(T92), T94, T94) → U5_GAA(T92, T94, lessB_in_ga(T92, T94))

The TRS R consists of the following rules:

maxC_in_gaa(s(T13), 0, s(T13)) → maxC_out_gaa(s(T13), 0, s(T13))
maxC_in_gaa(s(T23), s(T24), s(T23)) → U3_gaa(T23, T24, lessA_in_ag(T24, T23))
lessA_in_ag(0, s(T31)) → lessA_out_ag(0, s(T31))
lessA_in_ag(s(T38), s(T37)) → U1_ag(T38, T37, lessA_in_ag(T38, T37))
U1_ag(T38, T37, lessA_out_ag(T38, T37)) → lessA_out_ag(s(T38), s(T37))
U3_gaa(T23, T24, lessA_out_ag(T24, T23)) → maxC_out_gaa(s(T23), s(T24), s(T23))
maxC_in_gaa(0, T54, T54) → maxC_out_gaa(0, T54, T54)
maxC_in_gaa(s(T59), T61, T61) → U4_gaa(T59, T61, lessB_in_ga(T59, T61))
lessB_in_ga(0, s(T68)) → lessB_out_ga(0, s(T68))
lessB_in_ga(s(T73), s(T75)) → U2_ga(T73, T75, lessB_in_ga(T73, T75))
U2_ga(T73, T75, lessB_out_ga(T73, T75)) → lessB_out_ga(s(T73), s(T75))
U4_gaa(T59, T61, lessB_out_ga(T59, T61)) → maxC_out_gaa(s(T59), T61, T61)
maxC_in_gaa(s(T92), T94, T94) → U5_gaa(T92, T94, lessB_in_ga(T92, T94))
U5_gaa(T92, T94, lessB_out_ga(T92, T94)) → maxC_out_gaa(s(T92), T94, T94)

The argument filtering Pi contains the following mapping:
maxC_in_gaa(x1, x2, x3)  =  maxC_in_gaa(x1)
s(x1)  =  s(x1)
maxC_out_gaa(x1, x2, x3)  =  maxC_out_gaa
U3_gaa(x1, x2, x3)  =  U3_gaa(x3)
lessA_in_ag(x1, x2)  =  lessA_in_ag(x2)
lessA_out_ag(x1, x2)  =  lessA_out_ag(x1)
U1_ag(x1, x2, x3)  =  U1_ag(x3)
0  =  0
U4_gaa(x1, x2, x3)  =  U4_gaa(x3)
lessB_in_ga(x1, x2)  =  lessB_in_ga(x1)
lessB_out_ga(x1, x2)  =  lessB_out_ga
U2_ga(x1, x2, x3)  =  U2_ga(x3)
U5_gaa(x1, x2, x3)  =  U5_gaa(x3)
MAXC_IN_GAA(x1, x2, x3)  =  MAXC_IN_GAA(x1)
U3_GAA(x1, x2, x3)  =  U3_GAA(x3)
LESSA_IN_AG(x1, x2)  =  LESSA_IN_AG(x2)
U1_AG(x1, x2, x3)  =  U1_AG(x3)
U4_GAA(x1, x2, x3)  =  U4_GAA(x3)
LESSB_IN_GA(x1, x2)  =  LESSB_IN_GA(x1)
U2_GA(x1, x2, x3)  =  U2_GA(x3)
U5_GAA(x1, x2, x3)  =  U5_GAA(x3)

We have to consider all (P,R,Pi)-chains

(6) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

MAXC_IN_GAA(s(T23), s(T24), s(T23)) → U3_GAA(T23, T24, lessA_in_ag(T24, T23))
MAXC_IN_GAA(s(T23), s(T24), s(T23)) → LESSA_IN_AG(T24, T23)
LESSA_IN_AG(s(T38), s(T37)) → U1_AG(T38, T37, lessA_in_ag(T38, T37))
LESSA_IN_AG(s(T38), s(T37)) → LESSA_IN_AG(T38, T37)
MAXC_IN_GAA(s(T59), T61, T61) → U4_GAA(T59, T61, lessB_in_ga(T59, T61))
MAXC_IN_GAA(s(T59), T61, T61) → LESSB_IN_GA(T59, T61)
LESSB_IN_GA(s(T73), s(T75)) → U2_GA(T73, T75, lessB_in_ga(T73, T75))
LESSB_IN_GA(s(T73), s(T75)) → LESSB_IN_GA(T73, T75)
MAXC_IN_GAA(s(T92), T94, T94) → U5_GAA(T92, T94, lessB_in_ga(T92, T94))

The TRS R consists of the following rules:

maxC_in_gaa(s(T13), 0, s(T13)) → maxC_out_gaa(s(T13), 0, s(T13))
maxC_in_gaa(s(T23), s(T24), s(T23)) → U3_gaa(T23, T24, lessA_in_ag(T24, T23))
lessA_in_ag(0, s(T31)) → lessA_out_ag(0, s(T31))
lessA_in_ag(s(T38), s(T37)) → U1_ag(T38, T37, lessA_in_ag(T38, T37))
U1_ag(T38, T37, lessA_out_ag(T38, T37)) → lessA_out_ag(s(T38), s(T37))
U3_gaa(T23, T24, lessA_out_ag(T24, T23)) → maxC_out_gaa(s(T23), s(T24), s(T23))
maxC_in_gaa(0, T54, T54) → maxC_out_gaa(0, T54, T54)
maxC_in_gaa(s(T59), T61, T61) → U4_gaa(T59, T61, lessB_in_ga(T59, T61))
lessB_in_ga(0, s(T68)) → lessB_out_ga(0, s(T68))
lessB_in_ga(s(T73), s(T75)) → U2_ga(T73, T75, lessB_in_ga(T73, T75))
U2_ga(T73, T75, lessB_out_ga(T73, T75)) → lessB_out_ga(s(T73), s(T75))
U4_gaa(T59, T61, lessB_out_ga(T59, T61)) → maxC_out_gaa(s(T59), T61, T61)
maxC_in_gaa(s(T92), T94, T94) → U5_gaa(T92, T94, lessB_in_ga(T92, T94))
U5_gaa(T92, T94, lessB_out_ga(T92, T94)) → maxC_out_gaa(s(T92), T94, T94)

The argument filtering Pi contains the following mapping:
maxC_in_gaa(x1, x2, x3)  =  maxC_in_gaa(x1)
s(x1)  =  s(x1)
maxC_out_gaa(x1, x2, x3)  =  maxC_out_gaa
U3_gaa(x1, x2, x3)  =  U3_gaa(x3)
lessA_in_ag(x1, x2)  =  lessA_in_ag(x2)
lessA_out_ag(x1, x2)  =  lessA_out_ag(x1)
U1_ag(x1, x2, x3)  =  U1_ag(x3)
0  =  0
U4_gaa(x1, x2, x3)  =  U4_gaa(x3)
lessB_in_ga(x1, x2)  =  lessB_in_ga(x1)
lessB_out_ga(x1, x2)  =  lessB_out_ga
U2_ga(x1, x2, x3)  =  U2_ga(x3)
U5_gaa(x1, x2, x3)  =  U5_gaa(x3)
MAXC_IN_GAA(x1, x2, x3)  =  MAXC_IN_GAA(x1)
U3_GAA(x1, x2, x3)  =  U3_GAA(x3)
LESSA_IN_AG(x1, x2)  =  LESSA_IN_AG(x2)
U1_AG(x1, x2, x3)  =  U1_AG(x3)
U4_GAA(x1, x2, x3)  =  U4_GAA(x3)
LESSB_IN_GA(x1, x2)  =  LESSB_IN_GA(x1)
U2_GA(x1, x2, x3)  =  U2_GA(x3)
U5_GAA(x1, x2, x3)  =  U5_GAA(x3)

We have to consider all (P,R,Pi)-chains

(7) DependencyGraphProof (EQUIVALENT transformation)

The approximation of the Dependency Graph [LOPSTR] contains 2 SCCs with 7 less nodes.

(8) Complex Obligation (AND)

(9) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

LESSB_IN_GA(s(T73), s(T75)) → LESSB_IN_GA(T73, T75)

The TRS R consists of the following rules:

maxC_in_gaa(s(T13), 0, s(T13)) → maxC_out_gaa(s(T13), 0, s(T13))
maxC_in_gaa(s(T23), s(T24), s(T23)) → U3_gaa(T23, T24, lessA_in_ag(T24, T23))
lessA_in_ag(0, s(T31)) → lessA_out_ag(0, s(T31))
lessA_in_ag(s(T38), s(T37)) → U1_ag(T38, T37, lessA_in_ag(T38, T37))
U1_ag(T38, T37, lessA_out_ag(T38, T37)) → lessA_out_ag(s(T38), s(T37))
U3_gaa(T23, T24, lessA_out_ag(T24, T23)) → maxC_out_gaa(s(T23), s(T24), s(T23))
maxC_in_gaa(0, T54, T54) → maxC_out_gaa(0, T54, T54)
maxC_in_gaa(s(T59), T61, T61) → U4_gaa(T59, T61, lessB_in_ga(T59, T61))
lessB_in_ga(0, s(T68)) → lessB_out_ga(0, s(T68))
lessB_in_ga(s(T73), s(T75)) → U2_ga(T73, T75, lessB_in_ga(T73, T75))
U2_ga(T73, T75, lessB_out_ga(T73, T75)) → lessB_out_ga(s(T73), s(T75))
U4_gaa(T59, T61, lessB_out_ga(T59, T61)) → maxC_out_gaa(s(T59), T61, T61)
maxC_in_gaa(s(T92), T94, T94) → U5_gaa(T92, T94, lessB_in_ga(T92, T94))
U5_gaa(T92, T94, lessB_out_ga(T92, T94)) → maxC_out_gaa(s(T92), T94, T94)

The argument filtering Pi contains the following mapping:
maxC_in_gaa(x1, x2, x3)  =  maxC_in_gaa(x1)
s(x1)  =  s(x1)
maxC_out_gaa(x1, x2, x3)  =  maxC_out_gaa
U3_gaa(x1, x2, x3)  =  U3_gaa(x3)
lessA_in_ag(x1, x2)  =  lessA_in_ag(x2)
lessA_out_ag(x1, x2)  =  lessA_out_ag(x1)
U1_ag(x1, x2, x3)  =  U1_ag(x3)
0  =  0
U4_gaa(x1, x2, x3)  =  U4_gaa(x3)
lessB_in_ga(x1, x2)  =  lessB_in_ga(x1)
lessB_out_ga(x1, x2)  =  lessB_out_ga
U2_ga(x1, x2, x3)  =  U2_ga(x3)
U5_gaa(x1, x2, x3)  =  U5_gaa(x3)
LESSB_IN_GA(x1, x2)  =  LESSB_IN_GA(x1)

We have to consider all (P,R,Pi)-chains

(10) UsableRulesProof (EQUIVALENT transformation)

For (infinitary) constructor rewriting [LOPSTR] we can delete all non-usable rules from R.

(11) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

LESSB_IN_GA(s(T73), s(T75)) → LESSB_IN_GA(T73, T75)

R is empty.
The argument filtering Pi contains the following mapping:
s(x1)  =  s(x1)
LESSB_IN_GA(x1, x2)  =  LESSB_IN_GA(x1)

We have to consider all (P,R,Pi)-chains

(12) PiDPToQDPProof (SOUND transformation)

Transforming (infinitary) constructor rewriting Pi-DP problem [LOPSTR] into ordinary QDP problem [LPAR04] by application of Pi.

(13) Obligation:

Q DP problem:
The TRS P consists of the following rules:

LESSB_IN_GA(s(T73)) → LESSB_IN_GA(T73)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.

(14) QDPSizeChangeProof (EQUIVALENT transformation)

By using the subterm criterion [SUBTERM_CRITERION] together with the size-change analysis [AAECC05] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:

  • LESSB_IN_GA(s(T73)) → LESSB_IN_GA(T73)
    The graph contains the following edges 1 > 1

(15) YES

(16) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

LESSA_IN_AG(s(T38), s(T37)) → LESSA_IN_AG(T38, T37)

The TRS R consists of the following rules:

maxC_in_gaa(s(T13), 0, s(T13)) → maxC_out_gaa(s(T13), 0, s(T13))
maxC_in_gaa(s(T23), s(T24), s(T23)) → U3_gaa(T23, T24, lessA_in_ag(T24, T23))
lessA_in_ag(0, s(T31)) → lessA_out_ag(0, s(T31))
lessA_in_ag(s(T38), s(T37)) → U1_ag(T38, T37, lessA_in_ag(T38, T37))
U1_ag(T38, T37, lessA_out_ag(T38, T37)) → lessA_out_ag(s(T38), s(T37))
U3_gaa(T23, T24, lessA_out_ag(T24, T23)) → maxC_out_gaa(s(T23), s(T24), s(T23))
maxC_in_gaa(0, T54, T54) → maxC_out_gaa(0, T54, T54)
maxC_in_gaa(s(T59), T61, T61) → U4_gaa(T59, T61, lessB_in_ga(T59, T61))
lessB_in_ga(0, s(T68)) → lessB_out_ga(0, s(T68))
lessB_in_ga(s(T73), s(T75)) → U2_ga(T73, T75, lessB_in_ga(T73, T75))
U2_ga(T73, T75, lessB_out_ga(T73, T75)) → lessB_out_ga(s(T73), s(T75))
U4_gaa(T59, T61, lessB_out_ga(T59, T61)) → maxC_out_gaa(s(T59), T61, T61)
maxC_in_gaa(s(T92), T94, T94) → U5_gaa(T92, T94, lessB_in_ga(T92, T94))
U5_gaa(T92, T94, lessB_out_ga(T92, T94)) → maxC_out_gaa(s(T92), T94, T94)

The argument filtering Pi contains the following mapping:
maxC_in_gaa(x1, x2, x3)  =  maxC_in_gaa(x1)
s(x1)  =  s(x1)
maxC_out_gaa(x1, x2, x3)  =  maxC_out_gaa
U3_gaa(x1, x2, x3)  =  U3_gaa(x3)
lessA_in_ag(x1, x2)  =  lessA_in_ag(x2)
lessA_out_ag(x1, x2)  =  lessA_out_ag(x1)
U1_ag(x1, x2, x3)  =  U1_ag(x3)
0  =  0
U4_gaa(x1, x2, x3)  =  U4_gaa(x3)
lessB_in_ga(x1, x2)  =  lessB_in_ga(x1)
lessB_out_ga(x1, x2)  =  lessB_out_ga
U2_ga(x1, x2, x3)  =  U2_ga(x3)
U5_gaa(x1, x2, x3)  =  U5_gaa(x3)
LESSA_IN_AG(x1, x2)  =  LESSA_IN_AG(x2)

We have to consider all (P,R,Pi)-chains

(17) UsableRulesProof (EQUIVALENT transformation)

For (infinitary) constructor rewriting [LOPSTR] we can delete all non-usable rules from R.

(18) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

LESSA_IN_AG(s(T38), s(T37)) → LESSA_IN_AG(T38, T37)

R is empty.
The argument filtering Pi contains the following mapping:
s(x1)  =  s(x1)
LESSA_IN_AG(x1, x2)  =  LESSA_IN_AG(x2)

We have to consider all (P,R,Pi)-chains

(19) PiDPToQDPProof (SOUND transformation)

Transforming (infinitary) constructor rewriting Pi-DP problem [LOPSTR] into ordinary QDP problem [LPAR04] by application of Pi.

(20) Obligation:

Q DP problem:
The TRS P consists of the following rules:

LESSA_IN_AG(s(T37)) → LESSA_IN_AG(T37)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.

(21) QDPSizeChangeProof (EQUIVALENT transformation)

By using the subterm criterion [SUBTERM_CRITERION] together with the size-change analysis [AAECC05] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:

  • LESSA_IN_AG(s(T37)) → LESSA_IN_AG(T37)
    The graph contains the following edges 1 > 1

(22) YES